using UnityEngine;

[RequireComponent(typeof(AttackProperties))]
public class Attack : MonoBehaviour
{
    [SerializeField] private AttackProperties _attackProperties;
    [SerializeField] private int _attackRange;
    [SerializeField] private int _attackRate;

    private void Start()
    {
        _attackProperties = GetComponent<AttackProperties>();
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        var attacked = collision.GetComponent<Attacked>();
        if (attacked != null) attacked.TakeDamage(_attackProperties.DamageOut());
    }
}